package com.myzk.example.core;

import com.myzk.example.consts.ResultCodeMsg;

import java.io.Serializable;

public class Result<T> implements Serializable {
    private String code;
    private String message;
    private boolean success;
    private T data;

    private String requestId;
    private long timestamp;

    public Result(){
        super();
        this.timestamp = System.currentTimeMillis();
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public void setCodeAndMessage(String code,String message){
        this.code = code;
        this.message = message;
    }

    public void setCodeAndMessage(ResultCodeMsg resultCodeMsg){
        this.code = resultCodeMsg.getCode();
        this.message = resultCodeMsg.getMessage();
    }

    public String getRequestId() {
        return requestId;
    }

    public void setRequestId(String requestId) {
        this.requestId = requestId;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    @Override
    public String toString() {
        return "Result{" +
                "code='" + code + '\'' +
                ", message='" + message + '\'' +
                ", success=" + success +
                ", data=" + data +
                ", requestId='" + requestId + '\'' +
                ", timestamp=" + timestamp +
                '}';
    }
}
